package com.dl.providepayment.controller;

import com.dl.pojo.CommonResult;
import com.dl.pojo.Payment;
import com.dl.providepayment.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ProjectName: mcroservices
 * @Package: com.dl.providepayment.controller
 * @ClassName: PaymentControler
 * @Author: 86977
 * @Description: ${description}
 * @Date: 2021/6/23 21:39
 * @Version: 1.0
 */
@RestController
@Slf4j
public class PaymentControler {


  @Autowired
  private PaymentService paymentService;

  @PostMapping("/payment/create")
  public CommonResult create(@RequestBody Payment dept){
    int i = paymentService.create(dept);
    log.info("***************插入成功*******"+i);
    if(i>0){
      return new CommonResult(200,"插入数据库成功",i);
    }else{
      return new CommonResult(444,"插入数据库失败",null);
    }
  }
  @GetMapping("/payment/get/{id}")
  public CommonResult queryById(@PathVariable("id") Long id){
    Payment payment = paymentService.queryById(id);
    log.info("***************查询成功*********"+payment);
    if(payment!=null){
      return new CommonResult(200,"查询成功",payment);
    }else{
      return new CommonResult(444,"查询失败",null);
    }
  }

}
